package com.lc.hongtai.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.lc.hongtai.R;

/**
 * @author http://blog.csdn.net/finddreams
 * @Description:gridview的Adapter
 */
public class MyGridAdapter extends BaseAdapter {
    private Context mContext;

    public String[] img_text = {"投资管理", "我的礼券", "我的资产", "债权管理", "邀请好友", "银行卡管理",
            "密码设置","",""};
    public int[] imgs = {R.mipmap.invest, R.mipmap.wodeliquan,
            R.mipmap.wodelzichan, R.mipmap.minezhaiquan,
            R.mipmap.yaoqing, R.mipmap.yihangka,
            R.mipmap.mimashezhi,R.drawable.shape_empty, R.drawable.shape_empty};

    public MyGridAdapter(Context mContext) {
        super();
        this.mContext = mContext;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return img_text.length;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
    /*        convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.grid_item, parent, false);*/
           /* View view = LayoutInflater.from(context).inflate(R.layout.list_invest_financial, null);
            MyInvestlistAdapter_New.ViewHolder vh = new MyInvestlistAdapter_New.ViewHolder(view);*/

            convertView = LayoutInflater.from(mContext).inflate(R.layout.grid_item, parent, false);
        }
        //	TextView tv = BaseViewHolder.get(convertView, R.id.tv_item);
        //	ImageView iv = BaseViewHolder.get(convertView, R.id.iv_item);
        TextView tv = null;
        ImageView iv = null;
        tv = BaseViewHolder.get(convertView, R.id.tv_item);
        iv = BaseViewHolder.get(convertView, R.id.iv_item);


        iv.setBackgroundResource(imgs[position]);

        tv.setText(img_text[position]);
        return convertView;
    }

}
